﻿<WindowView
    x:Class="Poet.Views.GoToLineView"
    Icon="/Poet;component/App.ico"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:converters="clr-namespace:Poet.Converters"
    WindowStartupLocation="CenterOwner"
    Title="{Localizing GoToLine}"
    Height="130" Width="300"
    ResizeMode="NoResize">

    <WindowView.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\Resources\XamlStore.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            
            <converters:GoToLineRangeToStringConverter x:Key="GoToLineRangeToStringConverter"/>

            <ControlTemplate x:Key="TextBoxErrorTemplate">
                <AdornedElementPlaceholder>
                    <Ellipse ToolTip="{Localizing ValueMustBeAnIntegerInTheAllowedRange}" 
                         Margin="5,0,5,0" Width="10" Height="10" HorizontalAlignment="Right">
                        <Ellipse.Fill>
                            <LinearGradientBrush>
                                <GradientStop Color="#11FF1111" Offset="0"/>
                                <GradientStop Color="#FFFF0000" Offset="1"/>
                            </LinearGradientBrush>
                        </Ellipse.Fill>
                    </Ellipse>
                </AdornedElementPlaceholder>
            </ControlTemplate>

            <Style TargetType="TextBox">
                <Style.Triggers>
                    <Trigger Property="Validation.HasError" Value="True">
                        <Setter Property="Validation.ErrorTemplate" Value="{StaticResource TextBoxErrorTemplate}"/>
                        <Setter Property="ToolTip">
                            <Setter.Value>
                                <Binding Path="(Validation.Errors)[0].ErrorContent"  RelativeSource="{x:Static RelativeSource.Self}"/>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </WindowView.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Label Grid.Row="0" Margin="12,0">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Localizing LineNumber}"/>
                <TextBlock Text=" "/>
                <TextBlock Text="{Binding Converter={StaticResource GoToLineRangeToStringConverter}}"/>
                <TextBlock Text=":"/>
            </StackPanel>
        </Label>

        <TextBox TabIndex="0" Grid.Row="1" Margin="12,0" Name="LineNumberTextBox" TextChanged="LineNumberTextBox_OnTextChanged" Text="{Binding LineNumber,   ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"/>
        <Button TabIndex="1" Content="{Localizing Ok}" Name="OkButton" IsDefault="True" Grid.Row="3" MinHeight="23" HorizontalAlignment="Right" VerticalAlignment="Bottom" MinWidth="75" Margin="0,12,93,12" Click="Button_Click"/>
        <Button TabIndex="2" Content="{Localizing Cancel}" IsCancel="True" Grid.Row="3" MinHeight="23" HorizontalAlignment="Right" VerticalAlignment="Bottom" MinWidth="75" Margin="0,12,12,12"/>
    </Grid>
</WindowView>
